﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="clr-namespace:Elysium.Parameters"
                    xmlns:controls="clr-namespace:Elysium.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/SharedResources.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/Themes/Ranges/ProgressBase.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate x:Key="HorizontalProgressBarTemplate" TargetType="{x:Type controls:ProgressBar}">
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                ClipToBounds="True"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Canvas x:Name="PART_Track">
                <Rectangle x:Name="PART_Indicator"
                           Fill="{TemplateBinding Foreground}"
                           StrokeThickness="0"
                           Canvas.Left="0" Canvas.Top="0"
                           Width="{Binding ElementName=PART_Track, Path=ActualWidth}" Height="{Binding ElementName=PART_Track, Path=ActualHeight}">
                    <Rectangle.LayoutTransform>
                        <ScaleTransform ScaleX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Percent}"/>
                    </Rectangle.LayoutTransform>
                </Rectangle>
                <Canvas x:Name="PART_BusyBar"
                        Canvas.Left="0" Canvas.Top="0"
                        Visibility="Hidden">
                    <Ellipse Fill="{TemplateBinding Foreground}"
                             StrokeThickness="0"
                             Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}"
                             Width="{TemplateBinding params:Progress.BusyElementSize}"
                             Height="{TemplateBinding params:Progress.BusyElementSize}"/>
                    <Ellipse Fill="{TemplateBinding Foreground}"
                             StrokeThickness="0"
                             Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}"
                             Width="{TemplateBinding params:Progress.BusyElementSize}"
                             Height="{TemplateBinding params:Progress.BusyElementSize}"/>
                    <Ellipse Fill="{TemplateBinding Foreground}"
                             StrokeThickness="0"
                             Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}"
                             Width="{TemplateBinding params:Progress.BusyElementSize}"
                             Height="{TemplateBinding params:Progress.BusyElementSize}"/>
                    <Ellipse Fill="{TemplateBinding Foreground}"
                             StrokeThickness="0"
                             Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}"
                             Width="{TemplateBinding params:Progress.BusyElementSize}"
                             Height="{TemplateBinding params:Progress.BusyElementSize}"/>
                    <Ellipse Fill="{TemplateBinding Foreground}"
                             StrokeThickness="0"
                             Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}"
                             Width="{TemplateBinding params:Progress.BusyElementSize}"
                             Height="{TemplateBinding params:Progress.BusyElementSize}"/>
                </Canvas>
            </Canvas>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="State" Value="Indeterminate"/>
                    <Condition Property="IsEnabled" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Property="Canvas.Left" Value="{Binding ElementName=PART_Indicator, Path=ActualWidth, Converter={StaticResource NumberPositiveToNegativeConverter}}"/>
                    <Setter TargetName="PART_Indicator" Property="LayoutTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleX="0.4"/>
                        </Setter.Value>
                    </Setter>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="State" Value="Busy"/>
                    <Condition Property="IsEnabled" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Property="Visibility" Value="Hidden"/>
                    <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
</ResourceDictionary>